package com.sxx.beautifulcity.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.PopupMenu;
import android.widget.TextView;
import android.widget.Toast;

import com.sxx.beautifulcity.R;
import com.sxx.beautifulcity.popmenu.CommonPopMenu;

import java.net.URL;

/**
 * Created by dllo on 15/10/28.
 * 景区周边详情
 */
public class AroundDetailActivity extends DialogBaseActivity implements View.OnClickListener {
    //定义接收上一个界面传过来的在这个界面拼接的id
    private String linksid;
    private WebView lineWv;
    private TextView titleTv , moreTv;
    private ImageView backIv;
    private String url;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.webview_line_detail);
        lineWv = (WebView) findViewById(R.id.lineWv);
        init();
    }

    /**
     * 初始化
     */
    private void init() {

        titleTv = (TextView) findViewById(R.id.titleTv);
        titleTv.setText("景区周边");
        backIv = (ImageView) findViewById(R.id.backIV);
        backIv.setOnClickListener(this);

        moreTv = (TextView) findViewById(R.id.moreTv);
        moreTv.setOnClickListener(this);

        showDialog();
        Intent intent = getIntent();
        linksid = intent.getStringExtra("linksid");
        linksid = linksid.replace("|", "%7C");
        url = "http://www.365960.com/plus/api/api_show.php?type=list_jd&str=" +
                linksid + "&start=0&end=10";
        lineWv.loadUrl(url);
        dismissDialog();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.backIV:
                Intent intent = new Intent(this , AroundActivity.class);
                startActivity(intent);
                finish();
                overridePendingTransition(R.anim.left_out, R.anim.right_into);
                break;
            case R.id.moreTv:
                PopupMenu menu = CommonPopMenu.setHelpShopPopMenu(v , url);
                break;
        }
    }
}
